/**
 * 包含easyui的扩展和常用的方法
 * 
 * @author liuyang
 * 
 * @version 20120806
 */

var dagong = $.extend({}, dagong);/* 定义全局对象，类似于命名空间或包的作用 */

/**
 * 
 * 取消easyui默认开启的parser
 * 
 * 在页面加载之前，先开启一个进度条
 * 
 * 然后在页面所有easyui组件渲染完毕后，关闭进度条
 * 
 * @author liuyang
 * 
 * @requires jQuery,EasyUI
 * 
 */
$.parser.auto = false;
$(function() {
	$.messager.progress({
		text : '页面加载中....',
		interval : 100
	});
	$.parser.parse(window.document);
	window.setTimeout(function() {
		$.messager.progress('close');
		if (self != parent) {
			window.setTimeout(function() {
				try {
					parent.$.messager.progress('close');
				} catch (e) {
				}
			}, 500);
		}
	}, 1);
	$.parser.auto = true;
});

/**
 * 使panel和datagrid在加载时提示
 * 
 * @author liuyang
 * 
 * @requires jQuery,EasyUI
 * 
 */
$.fn.panel.defaults.loadingMessage = '加载中....';
$.fn.datagrid.defaults.loadMsg = '加载中....';

/**
 * @author liuyang
 * 
 * @requires jQuery,EasyUI
 * 
 * 避免验证tip屏幕跑偏
 */
var removeEasyuiTipFunction = function() {
	window.setTimeout(function() {
		$('div.validatebox-tip').remove();
	}, 0);
};
$.fn.panel.defaults.onClose = removeEasyuiTipFunction;
$.fn.window.defaults.onClose = removeEasyuiTipFunction;
$.fn.dialog.defaults.onClose = removeEasyuiTipFunction;

/**
 * @author liuyang
 * 
 * @requires jQuery,EasyUI
 * 
 * 通用错误提示
 * 
 * 用于datagrid/treegrid/tree/combogrid/combobox/form加载数据出错时的操作
 */
var easyuiErrorFunction = function(XMLHttpRequest) {
	$.messager.progress('close');
	$.messager.alert('错误', XMLHttpRequest.responseText);
};
$.fn.datagrid.defaults.onLoadError = easyuiErrorFunction;
$.fn.treegrid.defaults.onLoadError = easyuiErrorFunction;
$.fn.tree.defaults.onLoadError = easyuiErrorFunction;
$.fn.combogrid.defaults.onLoadError = easyuiErrorFunction;
$.fn.combobox.defaults.onLoadError = easyuiErrorFunction;
$.fn.form.defaults.onLoadError = easyuiErrorFunction;

/**
 * @author liuyang
 * 
 * @requires jQuery,EasyUI
 * 
 * 为datagrid、treegrid增加表头菜单，用于显示或隐藏列，注意：冻结列不在此菜单中
 */
var createGridHeaderContextMenu = function(e, field) {
	e.preventDefault();
	var grid = $(this);/* grid本身 */
	var headerContextMenu = this.headerContextMenu;/* grid上的列头菜单对象 */
	if (!headerContextMenu) {
		var tmenu = $('<div style="width:100px;"></div>').appendTo('body');
		var fields = grid.datagrid('getColumnFields');
		for ( var i = 0; i < fields.length; i++) {
			var fildOption = grid.datagrid('getColumnOption', fields[i]);
			if (!fildOption.hidden) {
				$('<div iconCls="icon-ok" field="' + fields[i] + '"/>').html(fildOption.title).appendTo(tmenu);
			} else {
				$('<div iconCls="icon-empty" field="' + fields[i] + '"/>').html(fildOption.title).appendTo(tmenu);
			}
		}
		headerContextMenu = this.headerContextMenu = tmenu.menu({
			onClick : function(item) {
				var field = $(item.target).attr('field');
				if (item.iconCls == 'icon-ok') {
					grid.datagrid('hideColumn', field);
					$(this).menu('setIcon', {
						target : item.target,
						iconCls : 'icon-empty'
					});
				} else {
					grid.datagrid('showColumn', field);
					$(this).menu('setIcon', {
						target : item.target,
						iconCls : 'icon-ok'
					});
				}
			}
		});
	}
	headerContextMenu.menu('show', {
		left : e.pageX,
		top : e.pageY
	});
};
$.fn.datagrid.defaults.onHeaderContextMenu = createGridHeaderContextMenu;
$.fn.treegrid.defaults.onHeaderContextMenu = createGridHeaderContextMenu;

/**
 * @author liuyang
 * 
 * @requires jQuery,EasyUI
 * 
 * 防止panel/window/dialog组件超出浏览器边界
 * @param left
 * @param top
 */
var easyuiPanelOnMove = function(left, top) {
	var l = left;
	var t = top;
	if (l < 1) {
		l = 1;
	}
	if (t < 1) {
		t = 1;
	}
	var width = parseInt($(this).parent().css('width')) + 14;
	var height = parseInt($(this).parent().css('height')) + 14;
	var right = l + width;
	var buttom = t + height;
	var browserWidth = $(window).width();
	var browserHeight = $(document.body).height()>$(window).height()?$(document.body).height():$(window).height();
	if (right > browserWidth) {
		l = browserWidth - width;
	}
	if (buttom > browserHeight) {
		t = browserHeight - height;
	}	
	$(this).parent().css({ //修正面板位置 
		left : l,
		top : t
	});
	
};

$.fn.dialog.defaults.onMove = easyuiPanelOnMove;
$.fn.window.defaults.onMove = easyuiPanelOnMove;
$.fn.panel.defaults.onMove = easyuiPanelOnMove;

/**
 * @author liuyang
 * 
 * @requires jQuery,EasyUI
 * 
 * panel关闭时回收内存
 */
$.fn.panel.defaults.onBeforeDestroy = function() {
	var frame = $('iframe', this);
	try {
		if (frame.length > 0) {
			for ( var i = 0; i < frame.length; i++) {
				frame[i].contentWindow.document.write('');
				frame[i].contentWindow.close();
			}
			frame.remove();
			if ($.browser.msie) {
				CollectGarbage();
			}
		}
	} catch (e) {
	}
};

/**
 * @author liuyang
 * 
 * @requires jQuery,EasyUI
 * 
 * 扩展validatebox，添加验证两次密码功能
 */
$.extend($.fn.validatebox.defaults.rules, {
	eqPassword : {
		validator : function(value, param) {
			return value == $(param[0]).val();
		},
		message : '密码不一致！'
	}
});

/**
 * @author liuyang
 * 
 * @requires jQuery,EasyUI
 * 
 * 扩展datagrid，添加动态增加或删除Editor的方法
 * 
 * 例子如下，第二个参数可以是数组
 * 
 * datagrid.datagrid('removeEditor', 'cpwd');
 * 
 * datagrid.datagrid('addEditor', [ { field : 'ccreatedatetime', editor : { type : 'datetimebox', options : { editable : false } } }, { field : 'cmodifydatetime', editor : { type : 'datetimebox', options : { editable : false } } } ]);
 * 
 */
$.extend($.fn.datagrid.methods, {
	addEditor : function(jq, param) {
		if (param instanceof Array) {
			$.each(param, function(index, item) {
				var e = $(jq).datagrid('getColumnOption', item.field);
				e.editor = item.editor;
			});
		} else {
			var e = $(jq).datagrid('getColumnOption', param.field);
			e.editor = param.editor;
		}
	},
	removeEditor : function(jq, param) {
		if (param instanceof Array) {
			$.each(param, function(index, item) {
				var e = $(jq).datagrid('getColumnOption', item);
				e.editor = {};
			});
		} else {
			var e = $(jq).datagrid('getColumnOption', param);
			e.editor = {};
		}
	}
});

/**
 * @author liuyang
 * 
 * @requires jQuery,EasyUI
 * 
 * 扩展datagrid的editor
 * 
 * 增加带复选框的下拉树
 * 
 * 增加日期时间组件editor
 * 
 * 增加多选combobox组件
 */
$.extend($.fn.datagrid.defaults.editors, {
	combocheckboxtree : {
		init : function(container, options) {
			var editor = $('<input />').appendTo(container);
			options.multiple = true;
			editor.combotree(options);
			return editor;
		},
		destroy : function(target) {
			$(target).combotree('destroy');
		},
		getValue : function(target) {
			return $(target).combotree('getValues').join(',');
		},
		setValue : function(target, value) {
			$(target).combotree('setValues', dagong.getList(value));
		},
		resize : function(target, width) {
			$(target).combotree('resize', width);
		}
	},
	datetimebox : {
		init : function(container, options) {
			var editor = $('<input />').appendTo(container);
			editor.datetimebox(options);
			return editor;
		},
		destroy : function(target) {
			$(target).datetimebox('destroy');
		},
		getValue : function(target) {
			return $(target).datetimebox('getValue');
		},
		setValue : function(target, value) {
			$(target).datetimebox('setValue', value);
		},
		resize : function(target, width) {
			$(target).datetimebox('resize', width);
		}
	},
	multiplecombobox : {
		init : function(container, options) {
			var editor = $('<input />').appendTo(container);
			options.multiple = true;
			editor.combobox(options);
			return editor;
		},
		destroy : function(target) {
			$(target).combobox('destroy');
		},
		getValue : function(target) {
			return $(target).combobox('getValues').join(',');
		},
		setValue : function(target, value) {
			$(target).combobox('setValues', dagong.getList(value));
		},
		resize : function(target, width) {
			$(target).combobox('resize', width);
		}
	}
});

/**
 * @author liuyang
 * 
 * @requires jQuery,EasyUI
 * 
 * @param options
 */
dagong.dialog = function(options) {
	var opts = $.extend({
		modal : true,
		onClose : function() {
			$(this).dialog('destroy');
		}
	}, options);
	return $('<div/>').dialog(opts);
};

/**
 * 
 * 
 */
dagong.window = function(options) {
	var opts = $.extend({
		modal : true,
		onClose : function() {
			$(this).window('destroy');
		}
	}, options);
	return $('<div/>').window(opts);
};


/**
 * @author liuyang
 * 
 * @requires jQuery,EasyUI
 * 
 * @param title
 *            标题
 * 
 * @param msg
 *            提示信息
 * 
 * @param fun
 *            回调方法
 */
dagong.messagerConfirm = function(title, msg, fn) {
	return $.messager.confirm(title, msg, fn);
};

/**
 * @author liuyang
 * 
 * @requires jQuery,EasyUI
 */
dagong.messagerShow = function(options) {
	
	return $.messager.show(options);
	
	//return $.messager.show(options);
};

/**
 * @author liuyang
 * 
 * @requires jQuery,EasyUI
 */
dagong.messagerAlert = function(title, msg, icon, fn) {
	return $.messager.alert(title, msg, icon, fn);
};

/**
 * @author liuyang
 * 
 * @requires jQuery,EasyUI,jQuery cookie plugin
 * 
 * 更换EasyUI主题的方法
 * 
 * @param themeName
 *            主题名称
 */
dagong.changeTheme = function(themeName) {
	var $easyuiTheme = $('#easyuiTheme');
	var url = $easyuiTheme.attr('href');
	var href = url.substring(0, url.indexOf('themes')) + 'themes/' + themeName + '/easyui.css';
	$easyuiTheme.attr('href', href);

	var $iframe = $('iframe');
	if ($iframe.length > 0) {
		for ( var i = 0; i < $iframe.length; i++) {
			var ifr = $iframe[i];
			$(ifr).contents().find('#easyuiTheme').attr('href', href);
		}
	}

	$.cookie('easyuiThemeName', themeName, {
		expires : 7
	});
};

/**
 * @author liuyang
 * 
 * 获得项目根路径
 * 
 * 使用方法：dagong.bp();
 * 
 * @returns 项目根路径
 */
dagong.bp = function() {
	var curWwwPath = window.document.location.href;
	var pathName = window.document.location.pathname;
	var pos = curWwwPath.indexOf(pathName);
	var localhostPaht = curWwwPath.substring(0, pos);
	var projectName = pathName.substring(0, pathName.substr(1).indexOf('/') + 1);
	return (localhostPaht + projectName);
};

/**
 * @author liuyang
 * 
 * 使用方法:dagong.pn();
 * 
 * @returns 项目名称(/sshe)
 */
dagong.pn = function() {
	return window.document.location.pathname.substring(0, window.document.location.pathname.indexOf('\/', 1));
};

/**
 * @author liuyang
 * 
 * 增加formatString功能
 * 
 * 使用方法：dagong.fs('字符串{0}字符串{1}字符串','第一个变量','第二个变量');
 * 
 * @returns 格式化后的字符串
 */
dagong.fs = function(str) {
	for ( var i = 0; i < arguments.length - 1; i++) {
		str = str.replace("{" + i + "}", arguments[i + 1]);
	}
	return str;
};

/**
 * @author liuyang
 * 
 * 增加命名空间功能
 * 
 * 使用方法：dagong.ns('jQuery.bbb.ccc','jQuery.eee.fff');
 */
dagong.ns = function() {
	var o = {}, d;
	for ( var i = 0; i < arguments.length; i++) {
		d = arguments[i].split(".");
		o = window[d[0]] = window[d[0]] || {};
		for ( var k = 0; k < d.slice(1).length; k++) {
			o = o[d[k + 1]] = o[d[k + 1]] || {};
		}
	}
	return o;
};

/**
 * @author 郭华(夏悸)
 * 
 * 生成UUID
 * 
 * @returns UUID字符串
 */
dagong.random4 = function() {
	return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
};
dagong.UUID = function() {
	return (dagong.random4() + dagong.random4() + "-" + dagong.random4() + "-" + dagong.random4() + "-" + dagong.random4() + "-" + dagong.random4() + dagong.random4() + dagong.random4());
};

/**
 * @author liuyang
 * 
 * 获得URL参数
 * 
 * @returns 对应名称的值
 */
dagong.getUrlParam = function(name) {
	var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
	var r = window.location.search.substr(1).match(reg);
	if (r != null)
		return unescape(r[2]);
	return null;
};

/**
 * @author liuyang
 * 
 * 接收一个以逗号分割的字符串，返回List，list里每一项都是一个字符串
 * 
 * @returns list
 */
dagong.getList = function(value) {
	if (value != undefined && value != '') {
		var values = [];
		var t = value.split(',');
		for ( var i = 0; i < t.length; i++) {
			values.push('' + t[i]);/* 避免他将ID当成数字 */
		}
		return values;
	} else {
		return [];
	}
};

/**
 * @author liuyang
 * 
 * @requires jQuery
 * 
 * 判断浏览器是否是IE并且版本小于8
 * 
 * @returns true/false
 */
dagong.isLessThanIe8 = function() {
	return ($.browser.msie && $.browser.version < 8);
};

/**
 * @author liuyang
 * 
 * @requires jQuery
 * 
 * 将form表单元素的值序列化成对象
 * 
 * @returns object
 */
dagong.serializeObject = function(form) {
	var o = {};
	$.each(form.serializeArray(), function(index) {
		this['value'] = this['value'].replaceAll(" ","");
		if (o[this['name']]) {
			o[this['name']] = o[this['name']] + "," + this['value'];
		} else {
			o[this['name']] = this['value'];
		}
	});
	return o;
};

/**
 * 
 * 将JSON对象转换成字符串
 * 
 * @param o
 * @returns string
 */
dagong.jsonToString = function(o) {
	var r = [];
	if (typeof o == "string")
		return "\"" + o.replace(/([\'\"\\])/g, "\\$1").replace(/(\n)/g, "\\n").replace(/(\r)/g, "\\r").replace(/(\t)/g, "\\t") + "\"";
	if (typeof o == "object") {
		if (!o.sort) {
			for ( var i in o)
				r.push(i + ":" + obj2str(o[i]));
			if (!!document.all && !/^\n?function\s*toString\(\)\s*\{\n?\s*\[native code\]\n?\s*\}\n?\s*$/.test(o.toString)) {
				r.push("toString:" + o.toString.toString());
			}
			r = "{" + r.join() + "}";
		} else {
			for ( var i = 0; i < o.length; i++)
				r.push(obj2str(o[i]));
			r = "[" + r.join() + "]";
		}
		return r;
	}
	return o.toString();
};

/**
 * @author 郭华(夏悸)
 * 
 * 格式化日期时间
 * 
 * @param format
 * @returns
 */
Date.prototype.format = function(format) {
	if (isNaN(this.getMonth())) {
		return '';
	}
	if (!format) {
		format = "yyyy-MM-dd hh:mm:ss";
	}
	var o = {
		/* month */
		"M+" : this.getMonth() + 1,
		/* day */
		"d+" : this.getDate(),
		/* hour */
		"h+" : this.getHours(),
		/* minute */
		"m+" : this.getMinutes(),
		/* second */
		"s+" : this.getSeconds(),
		/* quarter */
		"q+" : Math.floor((this.getMonth() + 3) / 3),
		/* millisecond */
		"S" : this.getMilliseconds()
	};
	if (/(y+)/.test(format)) {
		format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
	}
	for ( var k in o) {
		if (new RegExp("(" + k + ")").test(format)) {
			format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
		}
	}
	return format;
};

/**
 * @author liuyang
 * 
 * @requires jQuery
 * 
 * 改变jQuery的AJAX默认属性和方法
 */
$.ajaxSetup({
	type : 'POST',
	error : function(XMLHttpRequest, textStatus, errorThrown) {
		$.messager.progress('close');
		$.messager.alert('错误', XMLHttpRequest.responseText);
	}
});






var share = {
	/**
	 * 跨框架数据共享接口
	 * @param	{String}	存储的数据名
	 * @param	{Any}		将要存储的任意数据(无此项则返回被查询的数据)
	 */
	data: function (name, value) {
		var top = window.top,
			cache = top['_CACHE'] || {};
		top['_CACHE'] = cache;

		return value !== undefined ? cache[name] = value : cache[name];
	},
	/**
	 * 数据共享删除接口
	 * @param	{String}	删除的数据名
	 */
	removeData: function (name) {
		var cache = window.top['_CACHE'];
		if (cache && cache[name]) delete cache[name];
	}
};




/**
 * 超出范围的字符换成省略号
 * @param str
 * @param sub_length
 * @returns
 */
dagong.suolve = function suolve(str,sub_length){   
	var end='';
	try{
    var temp1 = str.replace(/[^\x00-\xff]/g,"**");//精髓   
    var temp2 = temp1.substring(0,sub_length);   
    //找出有多少个*   
    var x_length = temp2.split("\*").length - 1 ;   
    var hanzi_num = x_length /2 ;   
    sub_length = sub_length - hanzi_num ;//实际需要sub的长度是总长度-汉字长度   
    var res = str.substring(0,sub_length);   
    if(sub_length < str.length ){   
        end  =res+"..." ;   
    }else{    
        end  = res ;   
    }   
	}catch(e){}
    return end ;   
} 

function showMessage(json,obj){
	if(obj){
		obj.dagong.messagerShow({
			height:130,
			width:300,
			timeout:5000,
			msg : json.msg,
			title : '提示'
		});
	}else if(opener){  //如果是open 出来的
		opener.window.top.dagong.messagerShow({
			height:130,
			width:300,
			timeout:5000,
			msg : json.msg,
			title : '提示'
		});
	}else if(parent.opener){  //如果是open 出来的
		parent.opener.window.top.dagong.messagerShow({
			height:130,
			width:300,
			timeout:5000,
			msg : json.msg,
			title : '提示'
		});
	}else{
		parent.dagong.messagerShow({
			height:130,
			width:300,
			timeout:5000,
			msg : json.msg,
			title : '提示'
		});
	}
}

function openModalDialog(src, width, height, showScroll){   
	window.showModalDialog (src,"","location:No;status:No;help:No;dialogWidth:"+width+";dialogHeight:"+height+";scroll:"+showScroll+";");   
}   
function openWin(src,name,width, height, showScroll){  
	//alert('sdfsdfsdf');
	var iTop=(window.screen.height-height)/2; 
	var iLeft=(window.screen.width-width)/2; 
	return window.open (src,parseInt(Math.random()*38),'height='+height+'px,width='+width+'px,top='+iTop+'px,left='+iLeft+'px,toolbar=no,menubar=no,scrollbars='+showScroll+', resizable=no,location=no, status=no') ;  
} 
function refreshParentPage(url){ 
	if(window.opener){ 
		if(url){ 
			window.opener.location.href = url; 
		}else{ 
			try{ 
				window.opener.refreshSelfPage(); 
			}catch(e){ 
				try{ 
					var tempUrl = window.opener.location.href; 
					if(tempUrl.indexOf("?")>0){ 
						window.opener.location.href = tempUrl+"&rnd="+Math.random(); 
					}else{ 
						window.opener.location.href = tempUrl+"?rnd="+Math.random(); 
					} 
				}catch(e){ 
				} 
			}   
		} 
	} 
} 
dagong.reloadpage = function reloadpage() {
	if(share.data('pjglpt')) {
		location.reload();
	}else {
		 if(window.opener.datagrid!=undefined) {
				window.opener.datagrid.datagrid('reload');
		 }else {
			    window.opener.$('#p2').panel('refresh','flowTaskNodeAction!daiBanGZ.action');
			    window.opener.$('#p4').panel('refresh','flowTaskNodeAction!yiBanGZ.action');
		}
		window.close();
	}
}

//处理键盘事件 禁止后退键（Backspace）密码或单行、多行文本框除外
function forbidBackSpace(e) {
    var ev = e || window.event; //获取event对象 
    var obj = ev.target || ev.srcElement; //获取事件源 
    var t = obj.type || obj.getAttribute('type'); //获取事件源类型 
    //获取作为判断条件的事件类型 
    var vReadOnly = obj.readOnly;
    var vDisabled = obj.disabled;
    //处理undefined值情况 
    vReadOnly = (vReadOnly == undefined) ? false : vReadOnly;
    vDisabled = (vDisabled == undefined) ? true : vDisabled;
    //当敲Backspace键时，事件源类型为密码或单行、多行文本的， 
    //并且readOnly属性为true或disabled属性为true的，则退格键失效 
    var flag1 = ev.keyCode == 8 && (t == "password" || t == "text" || t == "textarea") && (vReadOnly == true || vDisabled == true);
    //当敲Backspace键时，事件源类型非密码或单行、多行文本的，则退格键失效 
    var flag2 = ev.keyCode == 8 && t != "password" && t != "text" && t != "textarea";
    //判断 
    if (flag2 || flag1) return false;
}
//禁止后退键 作用于Firefox、Opera
document.onkeypress = forbidBackSpace;
//禁止后退键  作用于IE、Chrome
document.onkeydown = forbidBackSpace;


function flowLog(xiangMuJBXXBH,renWuJBXXBH){
	parent.dagong.dialog({
		title : '流程记录',
		href : 'flowTaskNodeAction!processLog.action?xiangMuJBXXBH='+xiangMuJBXXBH+'&renWuJBXXBH='+renWuJBXXBH,
		width : 650,
		height : 350,
		onLoad : function() {
			parent.$.messager.progress('close');
		}
	});	
}

function flowChart(ftn_ID){
	openWin('platform/WebFlow/webflowView.jsp?ftn_ID='+ftn_ID,'',1000, 750, 'no');
}
function flowBack(formID,url,ftn_ID,closePageFunction,needSelect){
	if(needSelect){
		share.data('tongguoform',$('#'+formID));
		var p = parent.dagong.dialog({
			title : '请选择',
			href : 'flowTemplateNodeAction!processBack.action?ftn_ID='+ftn_ID+'&completeUrl='+url+"?a=1",//加载页面    
			width : 450,
			height : 500,
			shadow : false,
			onLoad : function() {
				parent.$.messager.progress('close');
			},
			onDestroy : function(){
				closePageFunction();
			}
		});
		share.data('processNextDialog',p);
	}else{
		$('#'+formID).form('submit', {
			url : url+'?ftn_ID='+ftn_ID,
			success : function(d) {
				var json = $.parseJSON(d);
				showMessage(json);
				if (json.success) {
					closePageFunction();
				}
			}
		});		
	}
}

function flowComplete(formID,url,ftn_ID,closePageFunction,needSelect,lineStart,ftc_ID,xiangMuJBXXBH,userCode){ 
	if(xiangMuJBXXBH==undefined){
		xiangMuJBXXBH = '';
	}
	
	if(ftc_ID==undefined){
		ftc_ID = '';
	}
	if(lineStart==undefined){
		lineStart = '';
	}
	if(userCode==undefined){
		userCode = '';
	}
	try{
		if(needSelect){//选择步骤和人员
			share.data('tongguoform',$('#'+formID));
			var p = parent.dagong.dialog({
				title : '请选择',
				href : 'flowTemplateNodeAction!processNext.action?ftn_ID='+ftn_ID+'&lineStart='+lineStart+'&fln_UserCode='+userCode+'&ftc_ID='+ftc_ID+'&xiangMuJBXXBH='+xiangMuJBXXBH+'&completeUrl='+url+"?a=1",//加载页面    
				width : 450,
				height : 500,
				onLoad : function() {
					parent.$.messager.progress('close');
				},
				onDestroy : function(){
					closePageFunction();
				}
			});
			share.data('processNextDialog',p);
		}else{//不选择步骤和人员
			$('#'+formID).form('submit', {
				url : url+'?ftn_ID='+ftn_ID,
				success : function(d) {
					var json = $.parseJSON(d);
					showMessage(json);
					if(json.success) {					   
						closePageFunction();
					}
				}
			});
		}
	}catch(e){e.message}
}

function checkBoxSingleSelection(f){
	f.find('input[type=checkbox]').change(function() {//同一个name的checkbox 不能多选
		var name_temp = $(this).attr('name');
		var type = $(this).attr('value');
		var boxs = f.find('input[name='+name_temp+']');	
			for(var i=0;i<boxs.length;i++){
				if(type=='1'){		
					boxs[0].checked = true; 
					boxs[1].checked = false; 
				}else{
					boxs[0].checked = false; 
					boxs[1].checked = true; 
				}	 
			}
	});
}

function checkYJ(obj){
	if(obj.val().length==0||$.trim(obj.val())==0){
		parent.dagong.messagerShow({
			msg : '请输入必填项内容！',
			title : '<s:text name="prompt"></s:text>'
		});
		return false;
	}
	return true;
}
function checkFtn(ftn_Id) {
	var b = false;
	$.ajax({
		url :'flowTaskNodeAction!checkFtn.action?ftn_ID='+ftn_Id,
		dataType:'json',
		success :function(d) {
			if(d.success&&d.obj) {
				b = true;
			}else {
				parent.dagong.messagerShow({
					msg : '该任务已失效，无需办理！请尝试刷新页面！',
					title : '提示'
					});
			}
		},
		async:false
	});
	
	return b;
}


